home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asmgen3.arc / ASMGEN.DOC < prev    next >
Text File  |  1989-04-19  |  27KB  |  663 lines

  1. ************************************************************************
  2. *                                       *
  3. *   ASMGEN.COM - by J. Gersbach      and  J. Damke       (Ver. 2.01)           *
  4. *                                       *
  5. *   A program to generate cross-referenced assembly language code      *
  6. *   from any executable    file.                           *
  7. *                                       *
  8. *                                       *
  9. *                                       *
  10. *   Uploaded to    PCanada    by Mark    Magner     November 23, 1983           *
  11. *                                       *
  12. ************************************************************************
  13.  
  14.  
  15. *  PREFACE  *
  16.  
  17.  
  18. This program will generate 8086/87/88 assembly code text that is
  19. compatible  with  the IBM Personal Computer Macro Assembler from
  20. any executable diskette file up to 65,535 bytes.  The output can
  21. be  routed to the console or a diskette  file.  A reference list
  22. may  be generated  separately  or  embedded  at  the  appropiate
  23. instruction counter address in the assembly code.
  24.  
  25. Some  manual  touch  up will be required before reassembly,  but
  26. nearly all the typing is done for you  by  ASMGEN  and  anything
  27. questionable is marked with "??".
  28.  
  29. A  file  of  sequential instructions may be resident on the same
  30. diskette to indicate to  ASMGEN  which  addresses  contain code,
  31. bytes,  words,   or   strings.   This  file   may  also  include
  32. instructions to assume segment register  values  or  toggle  the
  33. output of  assembley  code  text,  generation  of  the reference
  34. table,  8087 mnemonics,  of the inclusion of embedded  reference
  35. information in the assembly file.
  36.  
  37. DEBUG  may  be  used  to  browse  through the executable file to
  38. determine the starting locations of code and data to develop the
  39. sequential  instruction  file.  It  is important  to  accurately
  40. specify these locations for  an  accurate  reference  tabel  and
  41. minimum touching up of the ASM output text.
  42.  
  43. The  number  of references within the file determines the amount
  44. of memory required since a reference tabel is  built  in  memory
  45. during the  first pass.  Disassembly is done from disk  and only
  46. one file sector is in memory at any given time. Therefore memory
  47. size does not limit the size of the file to be disassembled. 48K
  48. bytes of memory will be enough for most programs but a few  will
  49. need  64K  or 128K.  One diskette drive is sufficient but two is
  50. more convenient.
  51.  
  52.  
  53. *  STARTING ASMGEN  *
  54.  
  55. There are two ways to work with  ASMGEN:  either  by  using  the
  56. command menu or by calling ASMGEN with parameters. Following are
  57. the descriptions of both options.
  58.  
  59. *  USING THE ASMGEN MENU  *
  60.  
  61. The program is invoked by typing:  ASMGEN
  62.  
  63. You are then prompted for a file specification. Respond with the
  64. name  of the executable file from which you wish to generate the
  65. assembly  code.  The  executable  file  will  normally  have  an
  66. extension of .EXE or .COM.  ASMGEN will check this file spec for
  67. validity and then respond with a prompt that includes a  summary
  68. of  the  command  letters  indicating  that  you  may  give it a
  69. command.  The executable file contents are not checked for valid
  70. code  and  ASMGEN  will  try to dis-assemble text or  compressed
  71. BASIC files and produce unintelligible assembly code.
  72.  
  73. The commands are:
  74.  
  75. X filespec    This file spec replaces any previous executable
  76.         file spec.  The usual file extension is .COM
  77.         or .EXE
  78.  
  79.         EXAMPLE:  X DATE.COM
  80.  
  81.  
  82. A <filespec> The executable file is disassembled and the  assem-
  83.         bly  code  is routed to the specified file.  The
  84.         usual file extension is .ASM. If the filespec is
  85.         omitted, the output will default to the console.
  86.  
  87.         EXAMPLE:  A DATE.ASM
  88.  
  89. R <filespec>    The reference table is sent to the file specified.
  90.         The usual file extension is .TBL.  If the filespec
  91.         is omitted, the output will default to the console.
  92.  
  93.         EXAMPLE:  R DATE.TBL
  94.  
  95. Q        The program is terminated and control returned to
  96.         DOS.
  97.  
  98.  
  99. Each  time a command has been executed,  ASMGEN waits with a one
  100. line prompt for the next command.
  101.  
  102. X <filespec>, A <CON>, R <CON> or Q ?
  103.  
  104. The default filespec for each  command  is  shown  in  brackets.
  105. Enter the next command of your choice as described above.
  106.  
  107.  
  108. *  USING ASMGEN WITH PARAMETER CALLS  *
  109.  
  110. Up  to  three file specifications may be included when ASMGEN is
  111. first called from  DOS. The  executable  file's  name  is  given
  112. first, followed by specifications for the assembly and reference
  113. table files.
  114.  
  115. EXAMPLE:  ASMGEN DATE.COM, DATE.ASM, DATE.TBL
  116.  
  117. If a semicolon follows the last filespec,  ASMGEN will  exit  to
  118. DOS  when  the  command  has  been executed.  If no semicolon is
  119. entered,  ASMGEN will display the menu options     described  above
  120. and wait for further input after executing the command.
  121.  
  122. EXAMPLE:  ASMGEN DATE.COM, DATE.ASM;
  123.  
  124. If  the  filespec for the .ASM file and/or .TBL file is omitted,
  125. ASMGEN will generate first the .ASM file, then a .TBL file using
  126. the filename of the first filespec.
  127.  
  128. EXAMPLE:  ASMGEN  DATE.COM,,;  creates DATE.ASM and DATE.TBL and
  129.                    exits to DOS.
  130.  
  131. If  only the reference table  is  desired,  the dummy  name  NUL
  132. should be entered in place of an .ASM filespec
  133.  
  134. EXAMPLE:  ASMGEN DATE.COM, NUL, DATE.TBL
  135.  
  136. If  only  one filespec is given when the program is called,  the
  137. reference table is built in memory and then the menu options are
  138. displayed for further commands.
  139.  
  140. EXAMPLE:  ASMGEN DATE.COM
  141.  
  142.  
  143. *  PROGRAM EXECUTION  *
  144.  
  145. The  disassembly is done in two passes through the scource file.
  146. On pass #1,  the reference table is  built  in  memory  and  the
  147. actual  output is generated during pass #2.  Once the  reference
  148. table is established,  it remains in memory  until  an  X  or  Q
  149. command  is  issued,  and subsequent A and R command  executions
  150. skip pass #1.  This saves a lot of time when the executable file
  151. is large.
  152.  
  153. Three  contiguous  data  areas  are  built dynamically in memory
  154. during pass #1.  First is the compressed sequential  instruction
  155. list.  Second is a list of pointers for .EXE files that point to
  156. the locations of all relocatable variables in the program,  also
  157. arranged  in  numerical  order.  These  are  established  before
  158. reading any code.  Third, the reference table is then built in a
  159. higher area of memory as pass #1 progresses.
  160.  
  161. If  all available memory in the program segment is filled before
  162. the first two data areas are completed, ASMGEN will abort to the
  163. command prompt. After the reference table is started, a shortage
  164. of  memory  will produce the message "Reference Table Incomplete
  165. Due to Insufficient Memory" and continue.
  166.  
  167. Ctrl-Break  may  be  used  at any time to interrupt a command in
  168. progress.
  169.  
  170.  
  171. *  READING THE ASSEMBLY CODE FILE (.ASM)  *
  172.  
  173. This file begins with a title taken from the  executable  file's
  174. name and date followed by the current date (in brackets).
  175.  
  176. If  not  inhibited  by  the  M switch  in a .SEQ file (explained
  177. later), the macro library will appear next in the file.
  178.  
  179. Next will be  a  .RADIX  16  pseudo-op  which  tells  the  macro
  180. assembler that all numbers are in hexadecimal form.
  181.  
  182. Then comes a header that indicates a starting value for the code
  183. segment,  stack  segment,  instruction  pointer  and  the  stack
  184. pointer. The stack pointer is usually set to FFFF for .COM files
  185. but may be somewhat less depending on available  memory.   These
  186. values are passed by the linker for .EXE files.
  187.  
  188. The  first  ASSUME  statement  might  come  next.  There  is one
  189. generated for each segment that begins with  code.  All  segment
  190. registers  are  designated  according  to  the  current  set  of
  191. ASSUMEs.  They  will  sometimes  be  incorrect,  so  all  ASSUME
  192. statements should be checked prior to re-assembly.
  193.  
  194. The disassembled output follows,  terminated by an END statement
  195. and the execution address.   An ORG  psuedo-op  is  included  if
  196. required.
  197.  
  198. The  text  is  compatible  with  the IBM Macro Assembler and the
  199. format is the same except for RETurns.  To avoid  the  need  for
  200. PROCedure  titles,  special  mnemonics  are provided for all RET
  201. instructions.  These are defined in the  macro  library  at  the
  202. beginning  of  the  file.  Only  macros  that are needed for the
  203. current file are produced.  The optional embedded commands  that
  204. make up the reference table enhance the readability of the file.
  205. For very large  files,  this  is  sometimes  undesirable  and  a
  206. separate reference table is best.
  207.  
  208. When  invalid  instructions are encountered in code areas,  they
  209. are reproduced as byte values followed by "??".  If a near  jump
  210. is  defined previously in the code,  and it is within range of a
  211. short jump,  a NOP instruction is inserted after the  jump.  The
  212. executable  file  created  with  this  .ASM  file  and the Macro
  213. Assembler and Linker  will  then  be  the  same  length  as  the
  214. original  file.  This  makes  it less important to differentiate
  215. between labels and numeric constants since the label values  and
  216. their offsets within the file will be the same.  The fundamental
  217. problem of disassembly is in knowing if  the  original  assembly
  218. code  defined a number as a label which changes as a function of
  219. it's position or as a number that always remains  the  same.  If
  220. you make changes in the assembly code however, you must properly
  221. specify all values.  You might as well remove all  NOPs  at  the
  222. same time.
  223.  
  224. Labels are  five  characters  long and begin with "L".   Segment
  225. labels begin with "S".  The remaining characters are the current
  226. instruction  counter in hex form,  thus making each label unique
  227. and showing it's location in the original file.  The instruction
  228. counter  is  continuous  throughout  the  assembly  code without
  229. resetting at segment boundaries.  The segment labels are then in
  230. byte as opposed to paragraph form.  In those cases where a label
  231. value is modified by an ASSUME statement,  the original value is
  232. included  as a comment in the referencing instruction so that it
  233. may be easily changed back if it was not intended as a location.
  234.  
  235. The word "Relocatable" is printed at the end of  any  line  that
  236. contains an ablolute paragraph value.  These are values that DOS
  237. modifies after loading but before executing a program.  They are
  238. used  for  loading  segment  registers that are sensitive to the
  239. program location in menory.  Relocatable values are not modified
  240. by ASSUMEs. ASMGEN converts these numbers from paragraph to byte
  241. values by multiplying them by sixteen  so  that  they  will  fit
  242. within the 16-bit instruction counter field.  When the paragraph
  243. value is negative or exceeds 0FFFH,  it is left unchanged and  a
  244. warning (??) is issued on that line.  When a program larger than
  245. 64K bytes is being  disassembled,  it  should  be  divided  into
  246. smaller files.
  247.  
  248. All words are produced as labels, except when the "L" switch has
  249. been enacted in the .SEQ file (explained later).  The label name
  250. indicates  it's  numeric  value and,  if it does not occur on an
  251. instruction boundary,  the name indicates it's position relative
  252. to the current instruction pointer is given by an EQU statement.
  253. Therefore the Macro Assember will assume that it is a  location,
  254. but  it is easily changed to a constant since the value is given
  255. in the label name.  The word OFFSET precedes a label whenever it
  256. is questionable whether it is a label or an immediate value. You
  257. must decide which of the labels should be constants and which of
  258. the  constants should be labels,  and  change  them accordingly.
  259. When changing labels to numbers, be sure to append an "H" if the
  260. number ends  with a "D" or a "B" since  the Macro Assembler will
  261. otherwise assume that it is decimal or binary.
  262.  
  263. Bytes are always treated as constants. An optional switch may be
  264. included  in  the  .SEQ  file  (explained  later)  which enables
  265. numbers instead of labels if all references  to  the  value  are
  266. data segment and immediate operation types.
  267.  
  268. An effective procedure to follow in attempting to understand the
  269. assembly code file is to look first for the message  text  area,
  270. the input commands, and the simpler subroutines.  Then add label
  271. names to addresses in  the  .SEQ  file  (explained  later)  that
  272. remind the you of their purpose.  Add comments to the labels. If
  273. these names are well chosen, the larger routines eventually will
  274. become clear.  The embedded references are produced as labels so
  275. they will retain their meanings as they are changed.
  276.  
  277. It is also helpful to spend some time studying the structure  of
  278. data areas.  Vector tables, which are frequently used to control
  279. the program's flow, reveal the program's structure very quickly.
  280. If  some  routines  do not have labels  at the beginning,  it is
  281. usually because the code or tables that reference them  (or  the
  282. segment  register  assumptions)  are not properly defined in the
  283. .SEQ file.
  284.  
  285.  
  286. *  READING THE REFERENCE TABLE (.TBL)  *
  287.  
  288. A referencee is defined as a number that is referenced somewhere
  289. in  the  program.   It may  be  a  program loaction or a numeric
  290. constant.
  291.  
  292. A referencor is is defined as the address in  the  program  from
  293. which a reference is made to the referencee.
  294.  
  295. Each  entry  is  composed  of a referencEE followed by a list of
  296. referencors.  If  more than one line is needed, additional lines
  297. are indented to the first referencor position. The referencEE is
  298. followed by an "S" if it includes references to the beginning of
  299. segment. The referencor is followed by two letters, the first of
  300. which  represents  the  segment  register  that  is  implied  or
  301. prefixed  in  the  referencing  instruction.  The  second letter
  302. indicates the type of operation  on  the  referencEE.  When  the
  303. reference entries are embedded in the assembly code,  all values
  304. are preceded with the letter "L".
  305.  
  306. ----------------------------------------------------------------------------
  307. 1st letter    |  2nd letter
  308. SEG REGISTER    |  TYPE OF OPERATION
  309. ----------------------------------------------------------------------------
  310. C  code        |  J  jump       M  modify - INC, ADD, etc.
  311. S  stack    |  C  call       I  immediate - value or offset
  312. D  data        |  R  read       T  test or compare
  313. E  extra    |  W  write       ?  unknown or ESC instruction
  314.         |  P  port
  315. ----------------|-----------------------------------------------------------
  316.  
  317.  
  318.  
  319. *  WRITING/READING THE SEQUENTIAL INSTRUCTION FILE (.SEQ)  *
  320.  
  321. The  sequential  instruction  file  is   a   list   of   special
  322. instructions  to  ASMGEN which the user creates.  The file takes
  323. the form of a list of hexadecimal  addresses  and  single-letter
  324. instructions or generation switches. If used, the .SEQ file must
  325. be on the same diskette as the source file  and  have  the  same
  326. name  as  the  source  file  with  an  extension  of .SEQ.  Each
  327. instruction in the file must be in one of the following formats:
  328.  
  329. addr    command
  330. or
  331. addr    command        ;comment
  332. or
  333. addr    command        label    comment
  334. or
  335. addr    command        label    comment ;comment
  336.  
  337. "addr" represents the instruction pointer value. All addr values
  338. must be in numerical sequence in the file.
  339.  
  340. "command"  may  be  either  a  toggle  switch  or  a  generation
  341. instruction.
  342.  
  343. "label" is optional and replaces the label  generated  for  this
  344. address with this non-blank string.
  345.  
  346. "comment" is optional and must be preceded by "label" unless the
  347. dummy label "." is used. Everything following "label" is treated
  348. as an address comment and will be printed in the ASM file behind
  349. the generated instruction.  The address comment may be up to 255
  350. characters in length and should not contain a semi-colon.
  351.  
  352. ";comment"  is optional.  Anything following a semi-colon in the
  353. .SEQ file instructions is considered as a comment  in  the  .SEQ
  354. file only and is not added to the generated .ASM file.
  355.  
  356. "label"  and  "comment" are not allowed when a generation switch
  357. is coded,  but a ";comment" may be used to help clarify the .SEQ
  358. file.
  359.  
  360. The  .SEQ file is read into memory before the first pass starts.
  361. The addresses and commands will be compressed,  but "label"  and
  362. "comment"  will be held in memory one to one.  An effect of this
  363. is  that  memory space required for disassembly  increases  with
  364. each "label" and "comment" added to the .SEQ file.
  365.  
  366.  
  367. *  DESCRIPTION OF GENERATION SWITCHES  *
  368.  
  369. THE  VARIOUS TOGGLE SWITCHES ARE SET TO ON BY DEFAULT.  Switches
  370. may  be  toggled  on  and  off  at   any   point   in  the  .SEQ
  371. file/disassembly.
  372.  
  373. All  options  switches except /M and /H can be either toggled or
  374. directly set by the user.  A suffix of "+" turns the switch  ON,
  375. and  a suffix of "-" turns the switch OFF.  Switches encountered
  376. in the file that have neither of these suffixes are  toggled  to
  377. the opposite of their state at the time;  ON switches are turned
  378. OFF and OFF switches are turned ON.
  379.  
  380. /B - generate byte references
  381.  
  382. When ON,  byte and word references are included in the reference
  383. table. When OFF, only word references are generated.
  384.  
  385. /E - embedded references in ASM file
  386.  
  387. When  ON,  reference table entries are inserted in the text just
  388. before the referencee's definition statement.  When  OFF,  these
  389. entries are not included with the disassembled text.  The entire
  390. reference table can be printed with the "R" command.
  391.  
  392. /F - 8087 mnemonics
  393.  
  394. When  ON,   ESC  instructions   are  produced.  When   OFF,  ESC
  395. instructions  are  assumed  to be  8087  instructions  and  8087
  396. mnemonics are produced.
  397.  
  398. /H - append hex "H"
  399.  
  400. When this switch appears at any point in the .SEQ file,  an  "H"
  401. is appended to all hex numbers.  This does not, of course, apply
  402. to the labels which are hex values preceded by the  letter  "L".
  403. The  .RADIX 16 pseudo-op is omitted which allows the assembler's
  404. radix to default to  decimal.  This  switch  defaults  to  NO  H
  405. APPEND.  Note  that  it  will be set only once.  It retains it's
  406. value until the next .SEQ file is read.
  407.  
  408. /L - generate label or number
  409.  
  410. When ON, all word references are treated as labels.  When OFF, a
  411. word  reference  is treated as a constant if all referencors are
  412. data immediate types.
  413.  
  414. /M - suppress macro library
  415.  
  416. When this switch appears at any point in the .SEQ file, no macro
  417. library is included in the text output.  The DEFAULT IS THAT THE
  418. MACRO LIBRARY WILL BE INCLUDED.  Note that this switch  will  be
  419. set only once. It retains it's value until the next .SEQ file is
  420. read.
  421.  
  422. /O - control ASM output
  423.  
  424. When ON, ASMGEN will output the generated text. When OFF, output
  425. will be suppressed.
  426.  
  427. /R - control TBL output
  428.  
  429. When ON,  ASMGEN will output the generated reference data.  When
  430. OFF, the reference table is not printed.
  431.  
  432. /T - control trace output
  433.  
  434. When ON,  up to 16 bytes of object code are included as comments
  435. in each line of the assembly code file.   When OFF,  object code
  436. is not included.
  437.  
  438.  
  439. *  DESCRIPTION OF .SEQ FILE COMMANDS  *
  440.  
  441. A - assume
  442.  
  443. The following lines contain  ASSUMptions  for  segment  register
  444. values.  They  become effective at the address specified by this
  445. instruction and may be modified  anywhere  in  the  disassembly.
  446. The required format for assumptions is:
  447.  
  448. & 0400  DS
  449.  
  450. The ampersand indicates a continuation of the A instruction.
  451.  
  452. In  this  example,  a  data  segment  beginning at a instruction
  453. pointer value of 400 will be assumed until another A instruction
  454. changes  it.  CS,  ES, and  SS  are also supported.  The segment
  455. assumptions are used for effective  address  calculations  only.
  456. The  code  segment  assumption  does  not affect the instruction
  457. pointer value.
  458.  
  459. B - bytes
  460.  
  461. The bytes encountered in the source file  are  assumed  to  have
  462. meaning as single byte values.
  463.  
  464. C - code
  465.  
  466. The bytes encountered in the source file are assumed to be valid
  467. 8088 machine language instructions.
  468.  
  469. D - generate data operand
  470.  
  471. The operand of the instructions is changed  to  immediate  data.
  472. Subsequent bytes are interpreted as "C" (code follows).
  473. --Appears to not work correctly if the /H shitch is set--
  474.  
  475. I - initial value for IP
  476.  
  477. The  hexadecimal  value  on  this line overrides the instruction
  478. pointer value at the beginning of the file - not to be  confused
  479. with  the address at which execution begins.  The default values
  480. are 0000 for EXE files and 0100H for COM and  other  files.  The
  481. execution address following the END statement is omitted if this
  482. option is invoked.
  483.  
  484. S - strings
  485.  
  486. The bytes encountered in the source file  are  assumed  to  form
  487. text. Quoted text is produced for printable ASCII characters and
  488. byte values for others.
  489.  
  490. # - defined length strings
  491.  
  492. The first byte encountered  in  the  source  file  contains  the
  493. length of  the  character  string  which  begins  with  the next
  494. encountered character.  This length value may be overridden by a
  495. subsequent SEQ file instruction.
  496.  
  497. $ - defined length strings
  498.  
  499. The  first  byte  encountered  in  the  source file contains the
  500. length of the  character  string  which  begins  with  the  next
  501. encountered  character plus the length byte itself.  This length
  502. value may be overridden by a subsequent SEQ file instruction.
  503.  
  504. W - words
  505.  
  506. Pairs of bytes encountered in the source  file  are  assumed  to
  507. have meaning as word values.
  508.  
  509. X - repeating data structure
  510.  
  511. A  cyclic  data  structure  is assumed to begin at the specified
  512. instruction pointer value.  The structure definition may  follow
  513. and is prefixed by an ampersand (&) to indicate the continuation
  514. of this instruction. If the definition does not follow, then the
  515. most recent definition is used.  If no structure is yet defined,
  516. then an error message is displayed.
  517.  
  518. The following elements may be used to define the structure:
  519.  
  520. & NNNN S  -  The next NNNN bytes are defined as string characters
  521. & NNNN B  -  The next NNNN bytes are defined as byte values
  522. & NNNN W  -  The next NNNN bytes are defined as word values
  523. & XXNN $ - The next sequence of bytes is defined as  NN  fields.
  524.          Each  field  consists of a length byte and a string
  525.          of  characters.   The  length  of  each   field  is
  526.          contained  in the first encountered byte.  The high
  527.          nibble (XX),  if non-zero,  is a bit  mask  of  the
  528.          length  field within the byte.  The length field is
  529.          right-justified within  the  byte  after  the  byte
  530.          value is sent to the output file.
  531.  
  532.  
  533.  
  534. *  EXAMPLES OF .SEQ COMMANDS  *
  535.  
  536. This  example  .SEQ  file shows all the possible instructions in
  537. the appropriate format.
  538.  
  539. ;All switches are on at the beginning.
  540. 0    /T    ;no object code as comments in output
  541. 0    /M    ;no macro library in output
  542. 0    /H    ;append "H" to all numbers
  543. 00H     A    ;assume the following segment values
  544. ;Note that the ampersand (&) indicates the extended ASSUME
  545. & 380    DS    ;the data segment starts at 380 hex
  546. & 380    ES    ;the extra segment starts at 380 hex
  547. 0200     I    ;initialize the instruction pointer to 200
  548. 0200    /F    ;introduce 8087 mnemonics (not ESC)
  549. 0200    /E    ;no embedded references
  550. 0200     C    ;code begins at 200
  551. 0203H     W    ;words are at 203
  552. 0207     C    ;more code starting here
  553. 220     X    ;complex data structure begins here
  554. & 3     W    ;words
  555. & 1     B    ;byte
  556. & 0E02     $    ;2 strings starting with the 2nd byte follow
  557.         ;bits 3,2,1 of the first byte contain the length of the
  558.         ;string including the length byte.
  559.         ;the high nibble (0E) is the mask.
  560.         ;see also # in summary below
  561. & 1     B    ;byte
  562.         ;the structure repeats until 351
  563. 351     B    ;bytes
  564. 358     C    ;more code
  565. 380     S    ;strings - list of messages
  566. 421     W    ;words
  567. 4FD    /B    ;no further byte references
  568. 502    /R    ;garbage here - turn off reference generation
  569. 502    /O    ;and output
  570. 600H    /O+    ;valid code - turn output back on
  571. 600    /R
  572. 600     C
  573. 1A60 /O-    ;output file about to fill diskette - turn  output
  574.         ;off but keep ;scanning for references. another run
  575.         ;will be needed to get the remaining code.
  576. 1B00    /D    ;treat operand as immediate data
  577. 1DFD    /B+    ;continue with byte references
  578. 1F45     W    user_prt    ;user provided labels will translate
  579. 2256     S    $MSG        ;to upper case
  580. ^Z        ;Ctrl-Z, End-of-file marker is necessary
  581.  
  582.  
  583. Comments may be included if preceded by a semicolon.
  584.  
  585. Alphabetic characters may be either upper or lower case.
  586.  
  587. An "H" may follow the hex address.
  588.  
  589.  
  590.  
  591. *  SAMPLE SESSION  *
  592.  
  593. The external command CHKDSK.COM  will serve  as an  example  for
  594. this  sample session because it is short.  The .SEQ file is also
  595. short and easy to generate.  Only  these  few  instructions  are
  596. needed.
  597.  
  598.  
  599. 0100  /T  ;include object code as comments in .ASM file
  600. 0100  /E  ;simpler output without references
  601. 04F7H  S  ;messages
  602. 04F7H /H  ;append "H" to numeric values
  603.  
  604. Using  DEBUG,  browse  through  CHKDSK.COM  to see how  this was
  605. arrived at.  Usually,  but not always,  the best procedure is to
  606. assume code.  If the code appears unintelligible,  display it in
  607. hex/ASCII.  If it is not text, assume bytes.  Label positions in
  608. the first disassembly may indicate that some locations should be
  609. words.  Next, generate the .ASM file by typing
  610.  
  611. ASMGEN CHKDSK.COM <enter>
  612. A          <enter>
  613.  
  614. The assembly code can be viewed on the screen.  Then type
  615.  
  616. A CHKDSK.ASM      <enter>
  617.  
  618. to save the assembly source code to a file.  Then,
  619.  
  620. R CHKDSK.TBL      <enter>
  621.  
  622. to save the cross-reference table to disk.
  623.  
  624. The Macro Assembler,  Link.exe and Exe2bin could now be used  to
  625. assemble  CHKDSK.ASM,  link  it to .EXE and convert it to a .COM
  626. file. No modification should be necessary in this case.
  627.  
  628. If working with code that is to be modified,  the  symbol  types
  629. must  be  correctly  specified as locations or as constants.  If
  630. they are constants, place them outside of any segment. The label
  631. names may then be changed to make the code more readable.
  632.  
  633.  
  634. There are several disassembly issues and errors that must be corrected.  
  635.  
  636.      1.) put the PAGE directive "PAGE  56,132" on a line near the top of 
  637.          the .ASM listing.
  638.  
  639.      2.) With the /H switch set, the number 0FFFF is not always provided 
  640.          with an "H" suffix.  It must be corrected by hand.  
  641.  
  642.      2a.) With the /H switch set, the immediate operand value generated 
  643.      with the D command will need to be patched with an H suffix.
  644.  
  645.      3.) .SYS type device driver files start at 0000, and need an ASSUME 
  646.      directive.  They also need a "0000  I" line to start disassembly 
  647.      at 0000H.  Two pointers to executable code are at 0006 and 0008.
  648.  
  649.      4.) Override operators BYTE PTR or WORD PTR are sometimes needed.
  650.  
  651.      5.) Most Microsoft MASM versions simply refuse to assemble certain 
  652.      disassembled instructions (usually LES or LDS instructions with 
  653.      an 8-bit register specified).  They actually assemble the code 
  654.      correctly, but doesn't like the construct and declare an assembly 
  655.      error.  In such cases, try using the IBM's MASM 1.00, it isn't 
  656.      as fussy about assembling such questionable code.
  657.  
  658.      6.) If a message 'Hex value error in /SEQ file' is displayed upon 
  659.      attempting to disassemble a file, it may be necessary to add a 
  660.      Ctrl-Z, End-of-file marker, at the end of the .SEQ file.
  661.  
  662.  
  663.